\(\int \frac {\cos ^2(x)}{(a+b \sin ^2(x))^2} \, dx\) [318]

   Optimal result
   Rubi [A] (verified)
   Mathematica [A] (verified)
   Maple [A] (verified)
   Fricas [B] (verification not implemented)
   Sympy [F(-1)]
   Maxima [A] (verification not implemented)
   Giac [A] (verification not implemented)
   Mupad [B] (verification not implemented)

Optimal result

Integrand size = 15, antiderivative size = 54 \[ \int \frac {\cos ^2(x)}{\left (a+b \sin ^2(x)\right )^2} \, dx=\frac {\arctan \left (\frac {\sqrt {a+b} \tan (x)}{\sqrt {a}}\right )}{2 a^{3/2} \sqrt {a+b}}+\frac {\tan (x)}{2 a \left (a+(a+b) \tan ^2(x)\right )} \]

[Out]

1/2*arctan((a+b)^(1/2)*tan(x)/a^(1/2))/a^(3/2)/(a+b)^(1/2)+1/2*tan(x)/a/(a+(a+b)*tan(x)^2)

Rubi [A] (verified)

Time = 0.08 (sec) , antiderivative size = 54, normalized size of antiderivative = 1.00, number of steps used = 3, number of rules used = 3, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.200, Rules used = {3270, 205, 211} \[ \int \frac {\cos ^2(x)}{\left (a+b \sin ^2(x)\right )^2} \, dx=\frac {\arctan \left (\frac {\sqrt {a+b} \tan (x)}{\sqrt {a}}\right )}{2 a^{3/2} \sqrt {a+b}}+\frac {\tan (x)}{2 a \left ((a+b) \tan ^2(x)+a\right )} \]

[In]

Int[Cos[x]^2/(a + b*Sin[x]^2)^2,x]

[Out]

ArcTan[(Sqrt[a + b]*Tan[x])/Sqrt[a]]/(2*a^(3/2)*Sqrt[a + b]) + Tan[x]/(2*a*(a + (a + b)*Tan[x]^2))

Rule 205

Int[((a_) + (b_.)*(x_)^(n_))^(p_), x_Symbol] :> Simp[(-x)*((a + b*x^n)^(p + 1)/(a*n*(p + 1))), x] + Dist[(n*(p
 + 1) + 1)/(a*n*(p + 1)), Int[(a + b*x^n)^(p + 1), x], x] /; FreeQ[{a, b}, x] && IGtQ[n, 0] && LtQ[p, -1] && (
IntegerQ[2*p] || (n == 2 && IntegerQ[4*p]) || (n == 2 && IntegerQ[3*p]) || Denominator[p + 1/n] < Denominator[
p])

Rule 211

Int[((a_) + (b_.)*(x_)^2)^(-1), x_Symbol] :> Simp[(Rt[a/b, 2]/a)*ArcTan[x/Rt[a/b, 2]], x] /; FreeQ[{a, b}, x]
&& PosQ[a/b]

Rule 3270

Int[cos[(e_.) + (f_.)*(x_)]^(m_)*((a_) + (b_.)*sin[(e_.) + (f_.)*(x_)]^2)^(p_.), x_Symbol] :> With[{ff = FreeF
actors[Tan[e + f*x], x]}, Dist[ff/f, Subst[Int[(a + (a + b)*ff^2*x^2)^p/(1 + ff^2*x^2)^(m/2 + p + 1), x], x, T
an[e + f*x]/ff], x]] /; FreeQ[{a, b, e, f}, x] && IntegerQ[m/2] && IntegerQ[p]

Rubi steps \begin{align*} \text {integral}& = \text {Subst}\left (\int \frac {1}{\left (a+(a+b) x^2\right )^2} \, dx,x,\tan (x)\right ) \\ & = \frac {\tan (x)}{2 a \left (a+(a+b) \tan ^2(x)\right )}+\frac {\text {Subst}\left (\int \frac {1}{a+(a+b) x^2} \, dx,x,\tan (x)\right )}{2 a} \\ & = \frac {\arctan \left (\frac {\sqrt {a+b} \tan (x)}{\sqrt {a}}\right )}{2 a^{3/2} \sqrt {a+b}}+\frac {\tan (x)}{2 a \left (a+(a+b) \tan ^2(x)\right )} \\ \end{align*}

Mathematica [A] (verified)

Time = 0.18 (sec) , antiderivative size = 59, normalized size of antiderivative = 1.09 \[ \int \frac {\cos ^2(x)}{\left (a+b \sin ^2(x)\right )^2} \, dx=\frac {\arctan \left (\frac {\sqrt {a+b} \tan (x)}{\sqrt {a}}\right )}{2 a^{3/2} \sqrt {a+b}}-\frac {\sin (2 x)}{2 a (-2 a-b+b \cos (2 x))} \]

[In]

Integrate[Cos[x]^2/(a + b*Sin[x]^2)^2,x]

[Out]

ArcTan[(Sqrt[a + b]*Tan[x])/Sqrt[a]]/(2*a^(3/2)*Sqrt[a + b]) - Sin[2*x]/(2*a*(-2*a - b + b*Cos[2*x]))

Maple [A] (verified)

Time = 0.49 (sec) , antiderivative size = 51, normalized size of antiderivative = 0.94

method result size
default \(\frac {\tan \left (x \right )}{2 a \left (a \left (\tan ^{2}\left (x \right )\right )+\left (\tan ^{2}\left (x \right )\right ) b +a \right )}+\frac {\arctan \left (\frac {\left (a +b \right ) \tan \left (x \right )}{\sqrt {a \left (a +b \right )}}\right )}{2 a \sqrt {a \left (a +b \right )}}\) \(51\)
risch \(-\frac {i \left (2 a \,{\mathrm e}^{2 i x}+b \,{\mathrm e}^{2 i x}-b \right )}{a b \left (-b \,{\mathrm e}^{4 i x}+4 a \,{\mathrm e}^{2 i x}+2 b \,{\mathrm e}^{2 i x}-b \right )}-\frac {\ln \left ({\mathrm e}^{2 i x}-\frac {2 i a^{2}+2 i a b +2 a \sqrt {-a^{2}-a b}+b \sqrt {-a^{2}-a b}}{b \sqrt {-a^{2}-a b}}\right )}{4 \sqrt {-a^{2}-a b}\, a}+\frac {\ln \left ({\mathrm e}^{2 i x}-\frac {-2 i a^{2}-2 i a b +2 a \sqrt {-a^{2}-a b}+b \sqrt {-a^{2}-a b}}{b \sqrt {-a^{2}-a b}}\right )}{4 \sqrt {-a^{2}-a b}\, a}\) \(224\)

[In]

int(cos(x)^2/(a+b*sin(x)^2)^2,x,method=_RETURNVERBOSE)

[Out]

1/2*tan(x)/a/(a*tan(x)^2+tan(x)^2*b+a)+1/2/a/(a*(a+b))^(1/2)*arctan((a+b)*tan(x)/(a*(a+b))^(1/2))

Fricas [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 114 vs. \(2 (42) = 84\).

Time = 0.34 (sec) , antiderivative size = 313, normalized size of antiderivative = 5.80 \[ \int \frac {\cos ^2(x)}{\left (a+b \sin ^2(x)\right )^2} \, dx=\left [\frac {4 \, {\left (a^{2} + a b\right )} \cos \left (x\right ) \sin \left (x\right ) + {\left (b \cos \left (x\right )^{2} - a - b\right )} \sqrt {-a^{2} - a b} \log \left (\frac {{\left (8 \, a^{2} + 8 \, a b + b^{2}\right )} \cos \left (x\right )^{4} - 2 \, {\left (4 \, a^{2} + 5 \, a b + b^{2}\right )} \cos \left (x\right )^{2} + 4 \, {\left ({\left (2 \, a + b\right )} \cos \left (x\right )^{3} - {\left (a + b\right )} \cos \left (x\right )\right )} \sqrt {-a^{2} - a b} \sin \left (x\right ) + a^{2} + 2 \, a b + b^{2}}{b^{2} \cos \left (x\right )^{4} - 2 \, {\left (a b + b^{2}\right )} \cos \left (x\right )^{2} + a^{2} + 2 \, a b + b^{2}}\right )}{8 \, {\left (a^{4} + 2 \, a^{3} b + a^{2} b^{2} - {\left (a^{3} b + a^{2} b^{2}\right )} \cos \left (x\right )^{2}\right )}}, \frac {2 \, {\left (a^{2} + a b\right )} \cos \left (x\right ) \sin \left (x\right ) + {\left (b \cos \left (x\right )^{2} - a - b\right )} \sqrt {a^{2} + a b} \arctan \left (\frac {{\left (2 \, a + b\right )} \cos \left (x\right )^{2} - a - b}{2 \, \sqrt {a^{2} + a b} \cos \left (x\right ) \sin \left (x\right )}\right )}{4 \, {\left (a^{4} + 2 \, a^{3} b + a^{2} b^{2} - {\left (a^{3} b + a^{2} b^{2}\right )} \cos \left (x\right )^{2}\right )}}\right ] \]

[In]

integrate(cos(x)^2/(a+b*sin(x)^2)^2,x, algorithm="fricas")

[Out]

[1/8*(4*(a^2 + a*b)*cos(x)*sin(x) + (b*cos(x)^2 - a - b)*sqrt(-a^2 - a*b)*log(((8*a^2 + 8*a*b + b^2)*cos(x)^4
- 2*(4*a^2 + 5*a*b + b^2)*cos(x)^2 + 4*((2*a + b)*cos(x)^3 - (a + b)*cos(x))*sqrt(-a^2 - a*b)*sin(x) + a^2 + 2
*a*b + b^2)/(b^2*cos(x)^4 - 2*(a*b + b^2)*cos(x)^2 + a^2 + 2*a*b + b^2)))/(a^4 + 2*a^3*b + a^2*b^2 - (a^3*b +
a^2*b^2)*cos(x)^2), 1/4*(2*(a^2 + a*b)*cos(x)*sin(x) + (b*cos(x)^2 - a - b)*sqrt(a^2 + a*b)*arctan(1/2*((2*a +
 b)*cos(x)^2 - a - b)/(sqrt(a^2 + a*b)*cos(x)*sin(x))))/(a^4 + 2*a^3*b + a^2*b^2 - (a^3*b + a^2*b^2)*cos(x)^2)
]

Sympy [F(-1)]

Timed out. \[ \int \frac {\cos ^2(x)}{\left (a+b \sin ^2(x)\right )^2} \, dx=\text {Timed out} \]

[In]

integrate(cos(x)**2/(a+b*sin(x)**2)**2,x)

[Out]

Timed out

Maxima [A] (verification not implemented)

none

Time = 0.39 (sec) , antiderivative size = 49, normalized size of antiderivative = 0.91 \[ \int \frac {\cos ^2(x)}{\left (a+b \sin ^2(x)\right )^2} \, dx=\frac {\tan \left (x\right )}{2 \, {\left ({\left (a^{2} + a b\right )} \tan \left (x\right )^{2} + a^{2}\right )}} + \frac {\arctan \left (\frac {{\left (a + b\right )} \tan \left (x\right )}{\sqrt {{\left (a + b\right )} a}}\right )}{2 \, \sqrt {{\left (a + b\right )} a} a} \]

[In]

integrate(cos(x)^2/(a+b*sin(x)^2)^2,x, algorithm="maxima")

[Out]

1/2*tan(x)/((a^2 + a*b)*tan(x)^2 + a^2) + 1/2*arctan((a + b)*tan(x)/sqrt((a + b)*a))/(sqrt((a + b)*a)*a)

Giac [A] (verification not implemented)

none

Time = 0.31 (sec) , antiderivative size = 77, normalized size of antiderivative = 1.43 \[ \int \frac {\cos ^2(x)}{\left (a+b \sin ^2(x)\right )^2} \, dx=\frac {\pi \left \lfloor \frac {x}{\pi } + \frac {1}{2} \right \rfloor \mathrm {sgn}\left (2 \, a + 2 \, b\right ) + \arctan \left (\frac {a \tan \left (x\right ) + b \tan \left (x\right )}{\sqrt {a^{2} + a b}}\right )}{2 \, \sqrt {a^{2} + a b} a} + \frac {\tan \left (x\right )}{2 \, {\left (a \tan \left (x\right )^{2} + b \tan \left (x\right )^{2} + a\right )} a} \]

[In]

integrate(cos(x)^2/(a+b*sin(x)^2)^2,x, algorithm="giac")

[Out]

1/2*(pi*floor(x/pi + 1/2)*sgn(2*a + 2*b) + arctan((a*tan(x) + b*tan(x))/sqrt(a^2 + a*b)))/(sqrt(a^2 + a*b)*a)
+ 1/2*tan(x)/((a*tan(x)^2 + b*tan(x)^2 + a)*a)

Mupad [B] (verification not implemented)

Time = 13.87 (sec) , antiderivative size = 50, normalized size of antiderivative = 0.93 \[ \int \frac {\cos ^2(x)}{\left (a+b \sin ^2(x)\right )^2} \, dx=\frac {\mathrm {atan}\left (\frac {\mathrm {tan}\left (x\right )\,\left (2\,a+2\,b\right )}{2\,\sqrt {a}\,\sqrt {a+b}}\right )}{2\,a^{3/2}\,\sqrt {a+b}}+\frac {\mathrm {tan}\left (x\right )}{2\,a\,\left (\left (a+b\right )\,{\mathrm {tan}\left (x\right )}^2+a\right )} \]

[In]

int(cos(x)^2/(a + b*sin(x)^2)^2,x)

[Out]

atan((tan(x)*(2*a + 2*b))/(2*a^(1/2)*(a + b)^(1/2)))/(2*a^(3/2)*(a + b)^(1/2)) + tan(x)/(2*a*(a + tan(x)^2*(a
+ b)))